package com.zhangzy.qm.dao;

import java.io.Serializable;
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.zhangzy.qm.util.Dao;

public class BaseDao<T> extends HibernateDaoSupport implements Dao<T> {

	public Object getObjectById(Class clazz, Object id) throws Exception {		
		return this.getHibernateTemplate().get(clazz, (Serializable)id);
	}

	public List getObjects(Class clazz) throws Exception {		
		return this.getHibernateTemplate().loadAll(clazz);
	}

	public void removeObject(Class clazz, Object id) throws Exception {
		getHibernateTemplate().delete(getObjectById(clazz,id));

	}

	public Object save(Object o){
		getHibernateTemplate().save(o);
		return o;
	}

	public void update(Object o) throws Exception {
		this.getHibernateTemplate().update(o);

	}

}
